 <?php 

$id = $_GET['id'];
//$username='trang';

include("../db/opendb.php");
include("functions.php");

$query = "select * from zillow_guesses where ID = $id";
$result = mysql_query($query) or die ("SQL Error".mysql_error());
$row = mysql_fetch_assoc($result);

$array[address] = $row['address'];
$array[city] = $row['city'];
$array[state] = $row['state'];
$array[current_price] = $row['current_price'];
$array[future_price] = $row['future_price'];
$array[future_zestimate] = $row['future_zestimate'];
$array[cur_date] = $row['cur_date'];
$array[future_date] = $row['future_date'];
$array[price_diff] = $row['price_difference'];
$array[percent_diff] = $row['percent_diff'];
$array[points] = $row['points'];

$query = "select count(ID) as total, sum(points) as tp, avg(points) as uap, avg(price_difference) as upd, avg(percent_diff) as upercentd from zillow_guesses where user_id = '".$row['user_id']."' and status = 'complete'";
$result = mysql_query($query) or die ("SQL Error".mysql_error());
$row = mysql_fetch_assoc($result);


$array[total_guesses] = $row['total'];
$array[total_points] = $row['tp'];
$array[user_average_points] = $row['uap'];
$array[user_average_diff_price] = $row['upd'];
$array[user_average_diff_percent] = $row['upercentd'];


echo serialize($array);

?>
